//
//  WCNPatientStatusTCell.m
//  WCN
//
//  Created by 杨鑫 on 15/7/2.
//  Copyright (c) 2015年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNPatientStatusTCell.h"
//
#import "Macros.h"

@interface WCNPatientStatusTCell ()

@property (weak, nonatomic) IBOutlet UIButton *monitor;
@property (weak, nonatomic) IBOutlet UIButton *turnDepart;
@property (weak, nonatomic) IBOutlet UIButton *caring;
@property (weak, nonatomic) IBOutlet UIButton *turnHospital;
@property (weak, nonatomic) IBOutlet UIButton *Discharged;
@property (weak, nonatomic) IBOutlet UIButton *dead;

@property (weak, nonatomic) UIButton *selectedButton;

@end

@implementation WCNPatientStatusTCell

- (void)awakeFromNib {
    // Initialization code
    
    self.monitor.layer.borderColor = kBorderColor.CGColor;
    self.monitor.layer.borderWidth = kOnePX;
    
    self.turnDepart.layer.borderColor = kBorderColor.CGColor;
    self.turnDepart.layer.borderWidth = kOnePX;
    
    self.caring.layer.borderColor = kBorderColor.CGColor;
    self.caring.layer.borderWidth = kOnePX;
    
    self.turnHospital.layer.borderColor = kBorderColor.CGColor;
    self.turnHospital.layer.borderWidth = kOnePX;
    
    self.Discharged.layer.borderColor = kBorderColor.CGColor;
    self.Discharged.layer.borderWidth = kOnePX;
    
    self.dead.layer.borderColor = kBorderColor.CGColor;
    self.dead.layer.borderWidth = kOnePX;
}

- (void)setStatus:(NSString *)status
{
    /*
     MONITORING("监测中"),
     NURSING("护理中"),
     DISCHARGED("已出院"),
     HOSPITAL_TRANSFERRED("转院"),
     DEPT_TRANSFERRED("转科室"),
     DEAD("死亡");
     */
    
    UIButton *selected;
    if ([@"MONITORING" isEqualToString:status]) {
        selected = self.monitor;
    } else if ([@"NURSING" isEqualToString:status]) {
        selected = self.caring;
    } else if ([@"DISCHARGED" isEqualToString:status]) {
        selected = self.Discharged;
    } else if ([@"HOSPITAL_TRANSFERRED" isEqualToString:status]) {
        selected = self.turnHospital;
    } else if ([@"DEPT_TRANSFERRED" isEqualToString:status]) {
        selected = self.turnDepart;
    } else if ([@"DEAD" isEqualToString:status]) {
        selected = self.dead;
    }
    
    selected.selected = YES;
    selected.backgroundColor = HexRGB(0x32baf4);
    selected.layer.borderColor = HexRGB(0x32baf4).CGColor;
    
    self.selectedButton = selected;
}

- (IBAction)statusClick:(id)sender {
    [self.selectedButton setSelected:NO];
    self.selectedButton.backgroundColor = [UIColor whiteColor];
    self.selectedButton.layer.borderColor = kBorderColor.CGColor;
    
    UIButton *btn = sender;
    btn.selected = YES;
    btn.backgroundColor = HexRGB(0x32baf4);
    btn.layer.borderColor = HexRGB(0x32baf4).CGColor;
    
    self.selectedButton = btn;
    
    NSArray *statusArray = @[@"MONITORING", @"NURSING", @"DISCHARGED", @"DEPT_TRANSFERRED", @"HOSPITAL_TRANSFERRED",  @"DEAD"];
    self.btnClick(statusArray[btn.tag-1]);
}

@end